import store from '@/store'

export const imgError = {
  inserted(dom, binding) {
  // dom就是绑定此指令的元素， binding包含了自定义指令的信息
    dom.onerror = function() {
      dom.src = binding.value
    }
  }
}

// 功能权限的自定义指令
export const has = {
  inserted(dom, binding) {
    function isCan(key) {
      return store.state.permission.roles.points.some(item => item === key)
    }
    if (!isCan(binding.value)) {
      dom.remove()
    }
  }
}
